package org.darcy.admin.task.pink;

import org.darcy.common.utils.DateUtil;
import org.darcy.service.service.StorePinkService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 拼团状态变化Task
 */
@Component
@Configuration
@EnableScheduling
public class PinkStatusChangeTask {

	// 日志
	private static final Logger logger = LoggerFactory.getLogger(PinkStatusChangeTask.class);

	@Autowired
	private StorePinkService storePinkService;

	@Scheduled(cron = "0 */1 * * * ?") // 每分钟执行一次
	public void init() {
		logger.info("拼团状态变化: {}", DateUtil.nowDateTimeStr());
		try {
			storePinkService.detectionStatus();
		} catch (Exception e) {
			logger.error("PinkStatusChange" + " | msg : " + e.getMessage());
		}

	}
}
